﻿namespace Sidvall.WorkItemManager.Net.Services.V1.Model
{
    public class ResourceFactory : global::Sidvall.Data.IResourceFactory
    {
        #region CreateItem

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
        public object CreateItem(string resource, Sidvall.Data.DataRowState? dataRowState)
        {
            switch (resource)
            {
                case global::Sidvall.WorkItemManager.Data.Model.DomainObjects.WorkCondition:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.WorkCondition(false, dataRowState, Sidvall.Business.BusinessEvents.UpdateState);
                case global::Sidvall.WorkItemManager.Data.Model.DomainObjects.Worker:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.Worker(false, dataRowState, Sidvall.Business.BusinessEvents.UpdateState);
                case global::Sidvall.WorkItemManager.Data.Model.DomainObjects.WorkItem:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.WorkItem(false, dataRowState, Sidvall.Business.BusinessEvents.UpdateState);
                case global::Sidvall.WorkItemManager.Data.Model.DomainObjects.WorkItemLog:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.WorkItemLog(false, dataRowState, Sidvall.Business.BusinessEvents.UpdateState);
                case global::Sidvall.WorkItemManager.Data.Model.DomainObjects.WorkItemSensor:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.WorkItemSensor(false, dataRowState, Sidvall.Business.BusinessEvents.UpdateState);
                case global::Sidvall.WorkItemManager.Data.Model.DomainObjects.WorkItemSensorLog:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.WorkItemSensorLog(false, dataRowState, Sidvall.Business.BusinessEvents.UpdateState);
                case global::Sidvall.WorkItemManager.Data.Model.DomainObjects.WorkItemType:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.WorkItemType(false, dataRowState, Sidvall.Business.BusinessEvents.UpdateState);
                case global::Sidvall.WorkItemManager.Data.Model.DomainObjects.WorkItemWorkCondition:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.WorkItemWorkCondition(false, dataRowState, Sidvall.Business.BusinessEvents.UpdateState);
                case global::Sidvall.WorkItemManager.Data.Model.DomainObjects.WorkRetryPolicy:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.WorkRetryPolicy(false, dataRowState, Sidvall.Business.BusinessEvents.UpdateState);
                default:
                    return null;
            }
        }

        #endregion
        #region CreateItems

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
        public object CreateItems(string resource)
        {
            switch (resource)
            {
                case global::Sidvall.WorkItemManager.Data.Model.DomainObjects.WorkCondition:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.WorkConditionCollectionItem();
                case global::Sidvall.WorkItemManager.Data.Model.DomainObjects.Worker:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.WorkerCollectionItem();
                case global::Sidvall.WorkItemManager.Data.Model.DomainObjects.WorkItem:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.WorkItemCollectionItem();
                case global::Sidvall.WorkItemManager.Data.Model.DomainObjects.WorkItemLog:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.WorkItemLogCollectionItem();
                case global::Sidvall.WorkItemManager.Data.Model.DomainObjects.WorkItemSensor:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.WorkItemSensorCollectionItem();
                case global::Sidvall.WorkItemManager.Data.Model.DomainObjects.WorkItemSensorLog:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.WorkItemSensorLogCollectionItem();
                case global::Sidvall.WorkItemManager.Data.Model.DomainObjects.WorkItemType:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.WorkItemTypeCollectionItem();
                case global::Sidvall.WorkItemManager.Data.Model.DomainObjects.WorkItemWorkCondition:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.WorkItemWorkConditionCollectionItem();
                case global::Sidvall.WorkItemManager.Data.Model.DomainObjects.WorkRetryPolicy:
                    return new global::Sidvall.WorkItemManager.Net.Services.V1.WorkRetryPolicyCollectionItem();
                default:
                    return null;
            }
        }
        
        #endregion
        
        #region Current

        private static readonly System.Lazy<ResourceFactory> _Current = new System.Lazy<ResourceFactory>(() => new ResourceFactory());
        public static ResourceFactory Current
        {
            get
            {
                return _Current.Value;
            }
        }

        #endregion
    }
}